import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'lib-flexible/flexible'


import {
    Notify,
    Search,
    Toast,
    Lazyload,
    Image,
    Dialog,
    Card,
    SwipeCell,
    Button,
    Icon,
    SubmitBar,
    Checkbox,
    List,
    Cell,
    PullRefresh,
    NavBar,
    ImagePreview,
    Field,
    Uploader


} from 'vant';
// const axios = require('axios');
import axios from "axios";
let ToastFunction = function(Puth, id) {
    // 判断是否登录
    let login = JSON.parse(localStorage.getItem("login"))
    if (this.$store.state.login === false || login === false) {
        this.Dialog.confirm({
            title: '登录提醒',
            message: '还没有登录是否登录',
            confirmButtonText: "是",
            cancelButtonText: "否"
        }).then(() => {
            //  去登录
            this.$router.push("/login/")
        }).catch(() => {
            //  不去登录
            localStorage.setItem("login", JSON.stringify(false));
            this.$store.state.login = false
        });
    } else if (id) {
        this.$store.state.DetailsID = id;
        console.log(Puth, this.$store.state.DetailsID);
        this.$router.push({ path: Puth + this.$store.state.DetailsID });

    } else {
        console.log(Puth)
        this.$router.push(Puth)


    }

}
let pathuiL = "http://192.168.1.104:9999/";
Vue.use(Card)
Vue.use(SwipeCell)
Vue.use(Button)
Vue.use(SubmitBar)
Vue.use(Checkbox)
Vue.use(List)
Vue.use(Cell)
Vue.use(Icon)
Vue.use(PullRefresh)
Vue.use(NavBar)
Vue.use(Lazyload)
Vue.use(Image)
Vue.use(ImagePreview)
Vue.use(Field)
Vue.use(Uploader)
Vue.prototype.pathuiL = pathuiL;
Vue.prototype.notify = Notify;
Vue.prototype.Toast = Toast;
Vue.prototype.axios = axios;
Vue.prototype.Dialog = Dialog;
Vue.prototype.ToastFunction = ToastFunction;
Vue.config.productionTip = false;
Vue.use(Search);
window.addEventListener('popstate', function(e) {
    router.isBack = true
}, false)
new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')